home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / glibc-1.09 / glibc-1 / glibc-1.09.1 / sysdeps / unix / bsd / ultrix4 / __sysconf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-18  |  1.8 KB  |  62 lines

  1. /* Copyright (C) 1992 Free Software Foundation, Inc.
  2.    Contributed by Ian Lance Taylor (ian@airs.com).
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. /* On Ultrix we can use the getsysinfo call to get the right return
  20.    value for _SC_CHILD_MAX.  Everything else is from <sys/param.h>,
  21.    which the default sysconf already knows how to handle.  */
  22.  
  23. #include <ansidecl.h>
  24. #include <unistd.h>
  25. #include <errno.h>
  26.  
  27. /* This is an Ultrix header file.  */
  28. #include <sys/sysinfo.h>
  29.  
  30. extern int EXFUN(__getsysinfo, (unsigned int op, void *buffer,
  31.                 size_t nbytes, int *start,
  32.                 void *arg));
  33. extern long int EXFUN(__default_sysconf, (int name));
  34.  
  35. long int
  36. DEFUN(__sysconf, (name), int name)
  37. {
  38.   if (name == _SC_CHILD_MAX)
  39.     {
  40.       int save = errno;
  41.       int start = 0;
  42.       int ret;
  43.  
  44.       /* getsysinfo returns the number of values it put into the
  45.      buffer, or 0 if not available, or -1 on error.  */
  46.       if (__getsysinfo (GSI_MAX_UPROCS, &ret, sizeof (ret), &start,
  47.             (void *) 0) > 0)
  48.     {
  49.       errno = save;
  50.       return ret;
  51.     }
  52.  
  53.       errno = save;
  54.     }
  55.  
  56.   return __default_sysconf (name);
  57. }
  58.  
  59. #define __sysconf __default_sysconf
  60.  
  61. #include <sysdeps/posix/__sysconf.c>
  62.